/**
  ******************************************************************************
  * @file    password_key_task.c
  * @author  MCU Application Team
  * @Version V1.0.0
  * @Date    2022-8-19
  * @brief   password_key_task function
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include "password_key.h"
#include "main.h"

/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
uint8_t rs485_addr = 0;             /*  拨码开关地址编码 */
/* Private function prototypes -----------------------------------------------*/


/*******************************************************************************
**功能描述 ：Rs485_Addr_Scan   循环扫描拨码开关地址
**输入参数 ：
**输出参数 ：
*******************************************************************************/
uint8_t Rs485_Addr_Scan(void)
{
    addr_typedef addr_key = {0};
    /* 扫描拨码开关地址 */
    addr_key.bit.bit0 = !BSP_PB_GetState( DIP_D1);
    addr_key.bit.bit1 = !BSP_PB_GetState( DIP_D2);
    addr_key.bit.bit2 = !BSP_PB_GetState( DIP_D3);
    addr_key.bit.bit3 = !BSP_PB_GetState( DIP_D4);
    rs485_addr =  addr_key.data &0x0F;
    return rs485_addr;
}

/************************ (C) COPYRIGHT Xinling *****END OF FILE****/
